<template>
  <div>
    <el-card class="introduce">
      <div class="order">
        <el-card class="box-card">
          <div slot="header" class="clearfix">
            <span>今日订单数</span>
          </div>
          <div class="text item">1888</div>
        </el-card>
        <el-card class="box-card">
          <div slot="header" class="clearfix">
            <span>今日日活</span>
          </div>
          <div class="text item">36271</div>
        </el-card>
        <el-card class="box-card">
          <div slot="header" class="clearfix">
            <span>转化率</span>
          </div>
          <div class="text item">20%</div>
        </el-card>
      </div>

      <div id="myChart"></div>
    </el-card>
  </div>
</template>


<script>

// import echarts from "echarts";

export default {
  data() {
    return {
      myChart: "",
      option: {
        title: {
          text: "展示折线图",
        },
        tooltip: {
          trigger: "axis",
          axisPointer: {
            type: "cross",
            label: {
              backgroundColor: "#6a7985",
            },
          },
        },
        legend: {
          data: [
            "新增注册",
            "付费用户",
            "活跃用户",
            "订单数",
            "当日收入",
          ],
        },
        toolbox: {
          feature: {
            saveAsImage: {},
          },
        },
        grid: {
          left: "3%",
          right: "4%",
          bottom: "3%",
          containLabel: true,
        },
        xAxis: [
          {
            type: "category",
            boundaryGap: false,
            data: ["2021-11-01", "2021-11-02", "2021-11-03", "2021-11-04", "2021-11-05", "2021-11-06", "2021-11-07"],
          },
        ],
        yAxis: [
          {
            type: "value",
          },
        ],
        series: [
          {
            name: "新增注册",
            type: "line",
            stack: "总量",
            areaStyle: { normal: {} },
            data: [120, 132, 101, 134, 90, 230, 210],
          },
          {
            name: "付费用户",
            type: "line",
            stack: "总量",
            areaStyle: { normal: {} },
            data: [220, 182, 191, 234, 290, 330, 310],
          },
          {
            name: "活跃用户",
            type: "line",
            stack: "总量",
            areaStyle: { normal: {} },
            data: [150, 232, 101, 154, 190, 330, 410],
          },
          {
            name: "订单数",
            type: "line",
            stack: "总量",
            areaStyle: { normal: {} },
            data: [320, 332, 301, 334, 190, 330, 320],
          },
          {
            name: "当日收入",
            type: "line",
            stack: "总量",
            areaStyle: { normal: {} },
            data: [310, 312, 301, 334, 390, 330, 320],
          },
        ],
      },
    };
  },
  methods: {
    drawLine(id) {
      // 基于准备好的dom，初始化echarts实例
      this.myChart = this.$echarts.init(document.getElementById(id));
      // 指定图表的配置项和数据
      this.myChart.setOption(this.option);
    },
  },
  //调用
  mounted() {
    this.$nextTick(function () {
      this.drawLine("myChart");
    });
  },
};
</script>

<style scoped>
.introduce .order {
  display: flex;
  margin-bottom: 50px;
}
.introduce .order .el-card {
  flex: 1;
  margin-right: 20px;
}
.introduce .order .order-item:last-child {
  margin-right: 0;
}
#myChart{
    width: 100%;
    height: 500px;
}
</style>
